package com.jiazhong.example.project.shoppingcart.util;

import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@Data
public class JsonResult<T> {
    // 返回的数据
    private T data;
    // 返回的状态码
    private Integer code;
    // 如果有错误返回错误信息
    private String error;
    // 是否成功返回
    private Boolean success;

    public JsonResult(T data) {
        this.data = data;
        this.success = true;
        this.code = 200;
    }

    public JsonResult(Integer code, String error) {
        this.code = code;
        this.error = error;
        this.success = false;
    }
}
